/*	******************************************
	File:		StateGameOver.cpp
	Author:		Adnan Srna, Peter Kober, Ivo Havranek
	Purpose:	AugmentedReality 2
	(up)Date:	March/April 2010
	Descr.:		game over at game
	Origin:		Salzburg University of Applied Science
	******************************************	*/

#include "StateGameOver.h"
//#include "StateGame.h"

StateGameOver::StateGameOver(){
	ofAddListener(ofEvents.keyPressed, this, &StateGameOver::keyPressed );
}

StateGameOver::~StateGameOver(){
	ofRemoveListener(ofEvents.keyPressed, this, &StateGameOver::keyPressed );
}

void StateGameOver::setup(/*StateManager* _manager*/)
{
//	manager = _manager;
	ofBackground(0, 0, 0);
	background.loadImage("images/gameover.png");
	textPosition = ofPoint(ofGetWidth()/2 - 111, ofGetHeight()/2 + 11);
	newPosition = ofPoint(0, 0);
	guiText.loadFont("calibri.ttf", 12, false, false, true);
	gameOverText.loadFont("calibri.ttf", 30);
}

// do the FFT calculation
void StateGameOver::update(){
	newPosition.x = (ofGetWidth()/4 - 50) * sin(2 * ofGetElapsedTimef());
	newPosition.y = (ofGetHeight()/3 - 50) * cos(ofGetElapsedTimef());
	cout << cos(sin(ofGetElapsedTimef())) << "\n";
}

// draw the FFT
void StateGameOver::draw(){
	ofSetColor(255, 255, 255, 255);
	background.draw(50, 50, ofGetWidth() - 100, ofGetHeight() - 100);
	drawGUI();
}


// check the keyboard input
void StateGameOver::keyPressed(ofKeyEventArgs& arg)
{
	switch(arg.key){
		/*
		case ' ':
			changeState(manager, new StateGame());
			break;*/
		case 'q':
			ofAppGlutWindow::exitApp();
			break;
	}
}

void StateGameOver::drawGUI(){
	ofSetColor(255, 255, 255);
	guiText.drawString("mmt08/HavI, KobP, SrnA - Augmented Reality2", 100, 15);
	guiText.drawString("[space]new Game OR [q]uit", 165, ofGetHeight()-15);
	ofSetColor(255 - 128*sin(ofGetElapsedTimef()), 255 - 128*cos(2*ofGetElapsedTimef()), 255 - 128*tan(ofGetElapsedTimef()));
	gameOverText.drawString("Game Over", textPosition.x + newPosition.x, textPosition.y + newPosition.y);
}
